package com.itheima.反射.反射的好处;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Properties;

/**
 * @Author 王加鑫
 * @Date 2021/5/26 17:04
 * @Version 1.0
 */
public class Test {
    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(new FileInputStream("day17_类加载器和反射/src/prop.properties"),"GBK");
        Properties properties = new Properties();
        properties.load(is);
        String className = properties.getProperty("className");
        String methodName = properties.getProperty("methodName");
        Class aClass = Class.forName(className);
        Constructor constructor = aClass.getConstructor();
        Object o = constructor.newInstance();
        Method method = aClass.getMethod(methodName);
        method.invoke(o);


    }
}
